package cn.csc.module.system.controller.admin.ip;

import cn.csc.framework.common.pojo.CommonResult;
import cn.csc.framework.ip.core.CompanyCode;
import cn.csc.framework.ip.core.utils.KuaiDi100CompanyCodeUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static cn.csc.framework.common.pojo.CommonResult.success;

/**
 * @author liuchuang
 * @version 1.0
 * @modify
 * @since 2025/7/9/0009 14:50
 */
@Api(tags = "管理后台 - 快递100快递公司标准编码")
@RestController
@RequestMapping("/system/kuaidi100")
@Validated
public class KuaiDi100CompanyCodeController {

    /**
     * 通过公司名称获取数据,可模糊匹配
     */
    @GetMapping("/byName")
    @ApiOperation("通过公司名称获取数据,可模糊匹配")
    public CommonResult<List<CompanyCode>> getByName(@RequestParam(name = "name", required = false, defaultValue = "") String name) {
        List<CompanyCode> byNames = KuaiDi100CompanyCodeUtils.getSimpleByName(name);
        return success(byNames);
    }

    /**
     * 通过公司编码获取数据
     */
    @GetMapping("/byCode")
    @ApiOperation("通过公司编码获取数据")
    public CommonResult<CompanyCode> getByCode(@RequestParam("code") String code) {
        CompanyCode byCode = KuaiDi100CompanyCodeUtils.getByCode(code);
        return success(byCode);
    }

}
